package exam.demo23;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-- != 0) {
            int h = in.nextInt();
            int a = in.nextInt();
            int H = in.nextInt();
            int A = in.nextInt();

            int num = 0;
            if(a >= H) {
                System.out.println(-1);
                return;
            }else {
                int n = H / a + (H % a == 0 ? 0 : 1); // 怪物能抗⼀下
                int m = n - 1; // 杀死⼀只怪物的时候，玩家被攻击⼏下
                num = h / (A * (n - 1)); // A * (n - 1): 杀死⼀只怪物的时候，玩家掉的⾎量
//                num = num - (h % (A * (n - 1)) == 0 ? 1 : 0);

                int h1 = h - (num - 1) * A * (n - 1); // 玩家剩余血量
                while (h1 > 0 && H > 0) {
                    H -= a;
                    if (H <= 0) {
                        break;
                    }
                    h1 -= A;
                    if (h1 <= 0) {
                        break;
                    }
                }
                if (H > 0) {
                    num--;
                }
            }
            System.out.println(num);
        }
    }
}
